﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOOL
{
    class TPublic
    {
        /// <summary>
        /// fontstyle字符串返回FontStyle类型
        /// </summary>
        /// <param name="_fontStyle">fontstyle字符串：Bold|Italic等</param>
        /// <returns>FontStyle类型</returns>
        public static FontStyle GetFontStyle(string _fontStyle)
        {
            //处理文字style
            FontStyle _style = FontStyle.Regular;
            if (_fontStyle.IndexOf('|') > 0)
            {
                string[] _sStyle = _fontStyle.Split('|');
                foreach (string item in _sStyle)
                {
                    switch (item)
                    {
                        case "Bold":
                            _style |= FontStyle.Bold;
                            break;
                        case "Italic":
                            _style |= FontStyle.Italic;
                            break;
                        case "Underline":
                            _style |= FontStyle.Underline;
                            break;
                        case "Strikeout":
                            _style |= FontStyle.Strikeout;
                            break;
                        default:
                            _style |= FontStyle.Regular;
                            break;
                    }
                }
            }
            else
            {
                switch (_fontStyle)
                {
                    case "Bold":
                        _style |= FontStyle.Bold;
                        break;
                    case "Italic":
                        _style |= FontStyle.Italic;
                        break;
                    case "Underline":
                        _style |= FontStyle.Underline;
                        break;
                    case "Strikeout":
                        _style |= FontStyle.Strikeout;
                        break;
                    default:
                        _style |= FontStyle.Regular;
                        break;
                }
            }
            return _style;
        }
    }
}
